<?php 
	class Model_mpro extends database{
		protected $_table = "tbl_products";
		protected $_cate  = "tbl_category";
		protected $_cago  = "tbl_categorie";
		public function get_pro($id){
			$sql = "select * from $this->_table where pro_id = '$id'";
			$this->query($sql);
			return $this->fetch();
		}
		public function total_pro(){
			$sql = "select * from $this->_table";
			$this->query($sql);
			return $this->num_rows();
		}
		public function list_pro($start,$limit){
			$sql = "select * from $this->_table order by pro_id DESC limit $start,$limit";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function list_cate(){
			$sql = "select * from $this->_cate where cate_status = '1' order by cate_id DESC";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function list_cago(){
			$sql = "select * from $this->_cago where cago_status = '1' order by cago_id DESC";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function list_pro_new($start,$limit){
			$sql = "select * from $this->_table where pro_new = '1' limit $start,$limit";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function total_pro_new(){
			$sql = "select * from $this->_table where pro_new = '1'";
			$this->query($sql);
			return $this->num_rows();
		}
		public function list_pro_hot($start,$limit){
			$sql = "select * from $this->_table where pro_hot = '1' limit $start,$limit";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function total_pro_hot(){
			$sql = "select * from $this->_table where pro_hot = '1' ";
			$this->query($sql);
			return $this->num_rows();
		}
		public function list_pro_saleoff($start,$limit){
			$sql = "select * from $this->_table where pro_saleoff = '1' limit $start,$limit";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function total_pro_saleoff(){
			$sql = "select * from $this->_table where pro_saleoff = '1' ";
			$this->query($sql);
			return $this->num_rows();
		}
		public function list_pro_bestsale($start,$limit){
			$sql = "select * from $this->_table where pro_bestsale = '1' limit $start,$limit";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function total_pro_bestsale(){
			$sql = "select * from $this->_table where pro_bestsale = 1";
			$this->query($sql);
			return $this->num_rows();
		}
		//List cate -> id
		
		public function get_cate($id){
			$sql = "select * from $this->_cate where cate_id = '$id'";
			$this->query($sql);
			return $this->fetch();
		}
		public function list_pro_cate($start,$limit,$id){
			$sql = "select * from $this->_table where cate_id = '$id' order by pro_id DESC limit $start,$limit";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function other_cate($start,$limit,$id1,$id2){
			$sql = "select * from $this->_table where cate_id = '$id1' and pro_id != '$id2' order by pro_id DESC limit $start,$limit";
			$this->query($sql);
			return $this->fetchAll();
		}
		public function total_cate($id){
			$sql = "select * from $this->_table where cate_id = '$id' ";
			$this->query($sql);
			return $this->num_rows();
		}
	}
	